#include <bits/stdc++.h>
using namespace std;
double d[100005],v[100005],a[100005];
int p[100005];
double calc(double v0,double a,double t){
	return v0*v0+2*a*(v0*t+0.5*a*t*t);
}
int main(){
	freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
		int flag=0;
		 double ans1=0,ans2=0;
         int n,m,l;
         double V;
         cin>>n>>m>>l>>V;
         for(int i=1;i<=n;i++){
			 cin>>d[i]>>v[i]>>a[i];
			 if(a[i]!=0) flag=1;
		 }
		 for(int k=1;k<=m;k++) cin>>p[k];
		 sort(p,p+m+1);
		 if(flag==0){
		 sort(p,p+m+1);
		 for(int i=1;i<=n;i++){
			 if(a[i]==0){
				 if(d[i]<=p[m]&&v[i]>V){
					 ans1++;
					 ans2=m-1;
				 }
			 }
		 }
		 if(ans1==0) ans2=m;
		 cout<<ans1<<" "<<ans2<<endl;
	     }
	     else{
			 double maxx=-1;
			 for(int i=1;i<=n;i++){
				if(v[i]>V&&d[i]<p[m]){
					ans1++;
					if(maxx<d[i]) maxx=d[i];
				}
				else if(v[i]<V){
				long double s=(V*V-v[i]*v[i])/(p[1]*a[i]);
				if(s+d[i]<=p[m]){
					ans1++;
					if(maxx<s+d[i]) maxx=s+d[i];
				}
			 }
			 else if(v[i]==V&&d[i]<p[m]) ans1++;
		 }
			 if(maxx>p[m]) cout<<ans1<<" "<<m<<endl;
			 else cout<<ans1<<" "<<m-1<<endl;
	    }
    }
    return 0;
}
